<?php

/*
* This script prints out all of the projects associated with a user.
* In order to use it, you should supply it with a 'user' header in a POST request
*
* @method POST	
* @header user The name of the user to lookup projects for
*
* @return mysql_error()
*          The mysql error that caused this program to halt if it fails
* @return html select form
*          HTML select for that contains each project as an option
*/


require_once("connect_to_database.php");


$query = sprintf("SELECT DISTINCT name from projects where participant='%s';",mysql_real_escape_string($_POST['user']));
$result = mysql_query($query);


if(!$result)
	die(mysql_error());

//Include confirmation dialog


//Display projects in a drop down list in alphabetical order
echo("<form action='user_projects/project.php' method='post' id='project_list'>");
echo("<select name='prname' style='width:280px'>");
while ($row = mysql_fetch_assoc($result)) {
	echo sprintf("<option value='%s'>".$row['name']."</option>", $row['name']);
}
echo("</select><br/><br/>");
echo("<input type='button' id='show_project' accesskey ='o' value='Open Project' onclick='showProject();' />&nbsp &nbsp &nbsp");
echo("<input type='button' id='delete_project' accesskey ='x' value='Delete Project' onclick='deleteProject();' />");
echo("</form>");

?>
